Camera and method for detecting image data

ABSTRACT

A camera for detecting an object in a detection zone is provided that has an image sensor for recording image data, a reception optics having a focus adjustment unit for setting a focal position, a distance sensor for measuring a distance value from the object, and a control and evaluation unit connected to the distance sensor and the focus adjustment unit to set a focal position in dependence on the distance value, and to determine a distance value with the distance sensor via a variable measurement duration that is predefined in dependence on a provisional distance value such that a measurement error of the distance value and thus, on a recording of image data of the object, a focus deviation of the set focal position from an ideal focal position remains small enough for a required image sharpness of the image data.

The invention relates to a camera and to a method of detecting imagedata of an object in a detection zone.

Cameras are used in a variety of ways in industrial applications toautomatically detect object properties, for example for the inspectionor for the measurement of objects. In this respect, images of the objectare recorded and are evaluated in accordance with the task by imageprocessing methods. A further use of cameras is the reading of codes.Objects with the codes located thereon are recorded using an imagesensor and the code zones are identified in the images and then decoded.Camera-based code readers also cope without problem with different codetypes than one-dimensional barcodes which also have a two-dimensionalstructure like a matrix code and provide more information. The automaticdetection of the text of printed addresses, (optical characterrecognition, OCR) or of handwriting is also a reading of codes inprinciple. Typical areas of use of code readers are supermarket cashregisters, automatic parcel identification, sorting of mail shipments,baggage handling at airports, and other logistic applications.

A frequent detection situation is the installation of the camera above aconveyor belt. The camera records images during the relative movement ofthe object stream on the conveyor belt and instigates further processingsteps in dependence on the object properties acquired. Such processingsteps comprise, for example, the further processing adapted to thespecific object at a machine which acts on the conveyed objects or achange to the object stream in that specific objects are expelled fromthe object stream within the framework of a quality control or theobject stream is sorted into a plurality of partial object streams. Ifthe camera is a camera-based code reader, the objects are identifiedwith reference to the affixed codes for a correct sorting or for similarprocessing steps.

The camera is frequently a part of a complex sensor system. It is, forexample, customary in reading tunnels on conveyor belts to install aplurality of camera-based code readers next to one another, on the onehand, to cover a larger conveyor belt width and, on the other hand, toinstall them from different perspectives to record objects from aplurality of sides. The geometry of the conveyed objects is furthermorefrequently measured in advance using a separate laser scanner todetermine focus information, release times, image zones with objects andthe like from it.

Without advance information of a laser scanner on the object spacings,whether an image is recorded in a focused focal position can bedetermined using the contrast. To set the focus in this manner, a largenumber of images have to be recorded and a good starting point is notinitially known. This is in particular problematic with a very smalldepth of field range because the contrasts outside the depth of fieldrange are highly blurred and it is thus difficult to indicate thedirection in which the focus adjustment should move.

Another option is to measure the distance from the object using thecamera itself. In this respect, however, an error in the distancemeasurement can become larger than the depth of field range, with theresult that the focal position set with reference to the distancemeasurement still does not result in the recording of focused images.

A distance sensor that is based on a time of flight (TOF) process isintegrated in a camera in DE 10 2018 105 301 A1. A height profile isthus measured and different functions are implemented with referencethereto. One of these functions is the setting of the focal position ofa reception optics. The accuracy of the distance measurement and of thesetting of the focal position is not discussed here.

It is therefore the object of the invention to achieve an improvedrecording of images in a focused focal position.

This object is satisfied by a camera and by a method of detecting imagedata an object in a detection zone in accordance with the respectiveindependent claim. An image sensor records images or image data of thedetection zone and thus of an object located there. To produce focusedimages, a focally adjustable reception optics is provided, that is areception objective, that has one or more lenses and other opticalelements depending on the quality demands. A distance sensor measures adistance value for the distance between the camera and the object to berecorded. A control and evaluation unit acts as a focus adjustment unit.For this purpose, it receives the distance value from the distancesensor and sets the focal position of the reception optics to thisdistance value. The control and evaluation unit is preferablyadditionally connected to the image sensor to read, pre-process,evaluate, and the like image data. Alternatively, there are respectiveseparate modules that take care of the focusing, on the one hand, andthe other tasks in the camera such as the processing of the image data.

The invention starts from the basic idea of measuring the distance valueusing a variable measurement duration. For the distance sensor measuresthe distance value the more accurately, the longer the measurementduration is available for the distance measurement. On the other hand,the demand on the accuracy of the distance measurement depends on thedistance the object is at since the depth of field range, and thus thedistance interval, in which a focus deviation between the set focalposition and the ideal focal position can be tolerated, has a distancedependence. To take them both into account, a tolerable focus deviationor a required precision of the setting of the foal position for arequired image sharpness is determined using a provisional distancevalue, in particular a provisional measurement of the distance sensorwith a still short measurement duration. The distance is then measuredover a measurement duration at which the distance value becomes at leastso accurate that the remaining measurement error is at most so large asthis still acceptable focus deviation. Again in other words, thedistance sensor measures over a measurement duration that ensures thatthe measurement error is small enough that the focal position thereuponset is within the depth of field range. The term depth of field rangemay not be interpreted too narrowly here, as explained below.

The invention has the advantage that a precise focusing is possible. Anyunnecessary inertia of the focus adjustment is simultaneously avoided bythe dynamic adaptation of the measurement duration to the accuracyactually required for the object specifically to be recorded, incontrast, for example, to if a constant long measurement duration hadbeen selected for the distance sensor in advance and independently ofthe distance. The distance sensor can itself already deliver a goodstarting value after a short measurement duration. This starting valueis already sufficient in certain distance ranges, in particular with alarge depth of field range in the far zone, because the measurementerrors are small enough. As soon as necessary, and only then, a longermeasurement duration is used to exactly set a focal position even withlittle play for a focus deviation, in particular with a small depth offield range in the near zone, still corresponding to the demands.

The distance sensor is preferably integrated in the camera. The systemthereby remains compact and encapsulated. The control and evaluationunit has simple internal access to the distance sensor.

The distance sensor is preferably configured as an optoelectronicdistance sensor, in particular in accordance with the principle of thetime of flight process. Such distance sensors are available as completedchips or modules. The distance sensor particularly preferably has aplurality of SPADs (single photon avalanche photodiodes) that eachmeasure a single time of flight via TDCs (time-to-digital converters).The measurement error can then be reduced via the number of individualtimes of flight that enter into a distance value by means of astatistical evaluation. A longer measurement period permits a multipletransmission and reception of light pulses and thus the detection ofmore exact distance values.

The control and evaluation unit is preferably configured to read a codecontent of a code on the object using the image data. The camera thusbecomes a camera-based code reader for barcodes and/or 2D codesaccording to various standards, optionally also for text recognition(optical character recognition, OCR). Before a code is read, asegmentation is even more preferably carried out by which regions ofinterest (ROIs) are identified as code candidates.

The control and evaluation unit is preferably configured toreparameterize the distance sensor for a respective distance measurementhaving a required measurement duration. The distance sensor is thusreconfigured for the respective measurement and subsequently delivers,with the now suitably selected measurement duration, a distance valuefor which it is ensured that the measurement errors are small enough.

The distance sensor is preferably configured to produce individualdistance measurement values after a fixed individual measurementduration, wherein the control and evaluation unit is configured to set arequired measurement duration as a multiple of the individualmeasurement duration by a plurality of individual measurements. In thisembodiment, the distance sensor already delivers a measurement valueafter a preferably short individual measurement duration. Its precisionis, however, at most sufficient for a part of the distance zone to becovered. Otherwise the measurement duration is extended by measurementrepeats so that a more exact distance measurement value can then becalculated from k individual distance measurement values.

The control and evaluation unit is preferably configured to determinethe distance value as a running average over a plurality of individualmeasurements. A running average has the advantage that a distancemeasurement value with corresponding statistics is already respectivelyavailable as required after a brief settling phase over the respectivehistory after a single further individual measurement.

The control and evaluation unit is preferably configured to reset therunning mean when an individual distance measurement value differs by atleast one threshold value from the previous running mean. A running meanremains valid as long as the same distance is still being measured inthe detection zone. If the object moves so that the distance fromanother object structure is now measured or if a different objectactually enters into the detection zone, the running mean would still befalsified by the previous distance and it is then better to restart theaveraging and to forget the history. This is assessed by a comparison ofthe result of a current individual measurement with the previous runningmean since the current individual measurement should be within theexpected distribution. If a threshold is exceeded in this comparison,the running mean is reset, i.e. a new running mean is determinedstarting from the current individual measurement. The threshold valuecan be made dependent on the current distance value, either the currentindividual measurement or the previous running mean, because largermeasurement errors are also to be expected with a larger distance andlarger fluctuations are therefore also permitted.

The provisional distance value is preferably an individual distancemeasurement value or a previous running average over some individualmeasurements. The required measurement duration to determine a distancehaving sufficiently small measurement errors depends on the objectdistance as explained in even more detail immediately from the nextparagraph onward. This object distance is, however, initially unknown sothat there seems to be a chicken-and-egg problem. This can, however,actually be resolved in that the measurement duration is determined inaccordance with the provisional distance value. The provisional distancevalue admittedly still suffers from too great a measurement error, butis accurate enough to fix the measurement duration, with optionally, forreasons of safety, a slight overestimation being able to be planned. Anindividual measurement or a running average over only some individualmeasurements can be used as the basis for the provisional distancevalue. In principle, the measurement duration could be tracked withincreasing accuracy of the running average after further measurementrepeats if it is found that the originally used provisional distancevalue deviated by too much and at least one further measurement repeatcould be appended, for example.

The control and evaluation unit is preferably configured to associate astill permitted focus deviation with a distance value while observing arequired image sharpness, in particular with reference to an associationrule or a table. It has previously above all been explained how ameasurement duration can be set and reached in that the distancemeasurement has sufficiently small measurement errors. It is now aquestion of the counter piece, namely which demands are to be made onthe measurement errors. For this purpose, the control and evaluationdevice is aware of an association between the distance and a focusdeviation still permitted for this distance. The still tolerable focusdeviation that results from the association with the provisionaldistance value explained in the previous paragraph limits the permittedmeasurement error and thus fixes the required measurement duration. Theassociation rule can in particular be predefined as an analyticalfunction or as an approximation, for example overall or piece by piecelinear polynomial function, or as a lookup table (LUT).

The required image sharpness is preferably reached when the object isrecorded in a depth of field range with the set focal position. This isensured via the measurement duration and the largest measurement errorsof the distance value thus achieved. The association of the distancevalue with the permitted focus deviation can here be expressed as anassociation between the provisional distance value and the associatedextent of the depth of field range. The depth of field range isaccordingly not defined purely physically in dependence on theembodiment, but can rather depend on which evaluation goal is pursued bythe image data.

The control and evaluation unit is preferably configured to determinethe depth of field range from optical properties. In this embodiment,the depth of field range is to be understood in the narrower optical orphysical sense. This can in particular be determined according to therule DOF_(P)(d)-d²Nc/f². DOF_(p) is here the physical depth of fieldrange (DOF=depth of field), d is the distance from the object, N is thenumerical aperture of the objective that is thus dependent on thef-number, c is the circle of confusion and corresponds to the degree ofpermitted blur such as a pixel on the image sensor, and f is the focallength of the reception optics. Most of these parameters are objectiveconstants of the selected reception optics and it can be recognized thatdue to the quadratic distance dependence of DOF_(p) on d, the distancemeasurement should have particularly small measurement errors in thenear zone.

The control and evaluation unit is preferably configured to determinethe depth of field range from application-specific demands. This is thefurther understanding of a depth of field range addressed multipletimes. It is here not primarily pure depth of field criteria that areimportant, but rather the question whether the image data will permitthe desired evaluation. This may have to be evaluated very differentlyfrom application to application.

The control and evaluation unit is preferably configured to read a codecontent of a code on the object using the image data, with a focusdeviation being small enough if the image sharpness therewith issufficient to read a code. This can be understood as a preferred case ofapplication-specific demands on the depth of field range; the imageshould namely be recorded so distinctly that a code can be read. Thisexpectation of when the image sharpness is sufficient to read a code canbe simulated in advance or can be generated by experiment. For thispurpose, codes are presented to the camera under typical conditions, forexample with reference to environmental light and print quality, atdifferent distances to determine the focus deviation up to which a codeis still read (GoodRead) or the focus deviation from which the code isno longer read (Noread).

The measurement duration to be set preferably depends on a code type, amodule size, for example indicated in pixels per module, and/or on adecoding process. They are parameters or settings that have aconsiderable effect on the image sharpness. In the terminology of anapplication-specific depth of field range, this in particular depends onsaid parameters.

The control and evaluation unit is preferably configured already to varythe focal position during the measurement duration. The focus adjustmentis therefore not delayed until a precise distance value is present afterthe set measurement duration. The focal position is rather alreadyadjusted in parallel with the distance measurement, for instance usingthe provisional distance value or a previously determined running meanfrom a plurality of individual distance values. A large part of theadjustment distance can thus already be covered during the measurementduration. The remaining fine adjustment then has much less of an effecton the inertia of the focus adjustment.

The camera is preferably installed in a stationary manner at a conveyingdevice that leads objects to be detected in a conveying directionthrough the detection zone. This is a very frequent industrialapplication of a camera. The focus adjustment practically has to be ableto react constantly and under tight time constraints due to theconstantly changing objects and the strict predetermination of theobject changes by the conveying device.

The method in accordance with the invention can be further developed ina similar manner and shows similar advantages in so doing. Suchadvantageous features are described in an exemplary, but not exclusivemanner in the subordinate claims dependent on the independent claims.

The invention will be explained in more detail in the following alsowith respect to further features and advantages by way of example withreference to embodiments and to the enclosed drawing. The Figures of thedrawing show in:

FIG. 1 a schematic sectional representation of a camera with a distancesensor;

FIG. 2 a three-dimensional view of an exemplary use of the camera in aninstallation at a conveyor belt;

FIG. 3 a representation of the measurement error of a distancemeasurement or of the extent of a depth of field range in dependence onthe object distance;

FIG. 4 a representation of successful and unsuccessful reading attemptsof a code on an object at different focal positions (X axis) and objectdistances (Y axis); and

FIG. 5 a representation of the measurement error of a distancemeasurement with respect to the number of individual measurementsentering into a running average, with a predefined extent of a depth offield range being drawn for comparison.

FIG. 1 shows a schematic sectional representation of a camera 10.Received light 12 from a detection zone 14 is incident on a receptionoptics 16 that conducts the received light 12 to an image sensor 18. Theoptical elements of the reception optics 16 are preferably configured asan objective composed of a plurality of lenses and other opticalelements such as diaphragms, prisms, and the like, but here onlyrepresented by a lens for reasons of simplicity. The reception optics 16can be set to different focal positions by means of a focus adjustment17 to record objects in focus at different distances. The most variedfunctional principles are conceivable for this purpose, for instance achange of the focal distance by a stepper motor or a moving coilactuator, but also a change of the focal length, for instance by aliquid lens or gel lens.

To illustrate the detection zone 14 with transmitted light 20 during arecording of the camera 10, the camera 10 comprises an optionalillumination unit 22 that is shown in FIG. 1 in the form of a simplelight source and without a transmission optics. In other embodiments, aplurality of light sources such as LEDs or laser diodes are arrangedaround the reception path, in ring form, for example, and can also bemulti-color and controllable in groups or individually to adaptparameters of the illumination unit 22 such as its color, intensity, anddirection.

In addition to the actual image sensor 18 for detecting image data, thecamera 10 has an optoelectronic distance sensor 24 that measuresdistances from objects in the detection zone 14 using a time of flight(TOF) process. The distance sensor 24 comprises a TOF light transmitter26 having a TOF transmission optics 28 and a TOF light receiver 30having a TOF reception optics 32. A TOF light signal 34 is thustransmitted and received again. A time of flight measurement unit 36determines the time of flight of the TOF light signal 34 and determinesfrom this the distance from an object at which the TOF light signal 34was reflected back.

The TOF light receiver 30 in the embodiment shown has a plurality oflight reception elements 30 a or pixels and can thus even detect aspatially resolved height profile. Alternatively, the TOF light receiver30 only has one light reception element 30 a or sets off a plurality ofmeasurement values of the light reception elements 30 a to one distancevalue. The design of the distance sensor 24 is purely exemplary andother optoelectronic distance measurements without time of flightprocesses and non-optical distance measurements are also conceivable.The optoelectronic distance measurement by means of time light processesis known and will therefore not be explained in detail. Two exemplarymeasurement processes are photomixing detection using a periodicallymodulated TOF light signal 34 and pulse time of flight measurement usinga pulse modulated TOF light signal 34. There are also highly integratedsolutions here in which the TOF light receiver 30 is accommodated on acommon chip with the time of flight measurement unit 36 or at leastparts thereof, for instance TDCs (time to digital converters) for timeof flight measurements. In particular a TOF light receiver 30 issuitable for this purpose that is designed as a matrix of SPAD (singlephoton avalanche diode) light reception elements 30 a. For such aSPAD-based distance measurement, a plurality of light reception elements30 a are particularly advantageous that are not used for a spatiallyresolved measurement, but rather for a statistical multiple measurementwith which a more exact distance value is determined. The TOF optics 28,32 are shown only symbolically as respective individual lensesrepresentative of any desired optics such as a microlens field.

A control and evaluation unit 38 is connected to the focus adjustment17, to the illumination unit 22, to the image sensor 18, and to thedistance sensor 24 and is responsible for the control work, theevaluation work, and for other coordination work in the camera 10. Ittherefore controls the focus adjustment 17 with a focal positioncorresponding to the distance value of the distance sensor 24 and readsimage data of the image sensor 18 to store them or to output them to aninterface 40. The control and evaluation unit 38 is preferably able tolocalize and decode code zones in the image data so that the camera 10becomes a camera-based code reader. A plurality of modules can beprovided for the different control and evaluation work, for example toperform the focus adaptations in a separate module or to performpre-processing of the image data on a separate FPGA.

The camera 10 is protected by a housing 42 that is terminated by a frontscreen 44 in the front region where the received light 12 is incident.

FIG. 2 shows a possible use of the camera 10 in an installation at aconveyor belt 46. The camera 10 is shown here only as a symbol and nolonger with its structure already explained with reference to FIG. 1.The conveyor belt 46 conveys objects 48, as indicated by the arrow 50,through the detection zone 14 of the camera 10. The objects 48 can bearcode zones 52 at their outer surfaces. It is the object of the camera 10to detect properties of the objects 48 and, in a preferred use as a codereader, to recognize the code zones 52, to read and decode the codesaffixed there, and to associate them with the respective associatedobject 48. In order also to detect object sides and in particularlaterally applied code zones 54, additional cameras 10, not shown, arepreferably used from different perspectives. In addition, a plurality ofcameras 10 can be arranged next to one another to together cover a widerdetection zone 14.

FIG. 3 shows by way of example by a gray line 56 the measurement errorof a distance measurement of the distance sensor 24 and by a black line58 the extent of a depth of field range in each case in dependence onthe object distance. The absolute measurement accuracy of the distancesensor 24 here increases linearly with the distance. The depth of fieldrange (DOF) is the distance zone in which the image of the camera 10 isdeemed usable There can be different criteria for this that will bediscussed below. The depth of field range is likewise dependent on thedistance, but becomes larger with the distance in a non-linear manner.

As can be recognized in FIG. 3, there is a distance zone in which thedepth of field range is smaller than the error of the distancemeasurement. Distances below approximately 30 cm are affected in thisexample. This means that a focal position adapted to this distancemeasurement cannot ensure any sufficiently focused image recording. Fora distance measurement that approximately makes use of the errorframework will lead to a focal position outside the depth of fieldrange. The depth of field range of the camera 10 could be increased bymeasures such as a better objective than reception optics 16. Thisoptimization potential is as a rule anyway already used as soon as theconsiderable effects on the manufacturing costs are acceptable and adistance zone would nevertheless remain in which this measure is noteffective.

The approach of the invention is therefore to instead improve theaccuracy of the distance measurement, and indeed in dependence on thedistance and adapted to the depth of field range given for therespective distance. This is above all of interest for distance zones inwhich the depth of field range is within the order of magnitude of theerror of the distance sensor 24.

Two questions have to be clarified for this approach. On the one hand,the distance sensor 24 has to measure respective distances having amaximum error. On the other hand, which maximum error actually has to beobserved so that a focus setting is good enough, that is delivers imageshaving a sufficient quality, has to be determined, with the latternaturally also implying criteria as to when the quality of an image issufficient. Since this should all be defined in dependence on the objectdistance, an at least rough initial value for the distance measurementis required. It is not a question of the accuracy here. Any measurementvalue for the distance is sufficient.

The measurement accuracy of the distance sensor 24 can be varied byvarying the measurement duration. Why a longer measurement durationresults in more accurate results can be easily illustrated for aSPAD-based pulse process. Each SPAD contributes an event or a time stampwith such a so-called direct time of flight (dTOF) measurement and theseevents are evaluated together statistically, for example via ahistogram. With a longer measurement duration, pulses can be repeatedlytransmitted so that more events are registered and accordingly thebetter statistics also enable a better measured result. Very generally,independently of the technology of the distance sensor 24, averaging cantake place over measurement repeats, with then the error falling withthe root of the number of measurement repeats, and a longer measurementduration permits a corresponding increase of this number.

The distance sensor 24 can be respectively reparameterized to vary themeasurement duration. This can, however, bring about transient effectsand it cannot be simply ensured that the reparameterization itself doesnot generate any systematic errors. The measurement behavior of thedistance sensor 24 is therefore preferably not affected at all, but anadaptive running average is rather formed. The distance sensor 24carries out respective individual measurements, for example in a pulseprocess by transmitting and receiving a pulse or fewer pulses. Theindividual distance values of these individual measurements are subjectto running averaging. The averaging window or the number k of respectiveaverages is adapted to the distance. A large averaging window or k istherefore selected for a small depth of field range, in particular inthe near zone, to reduce the statistical fluctuations. Conversely, witha large depth of field range, in particular in the far zone, a smallaveraging window or k is sufficient. The focus adjustment can thusalways react with the lowest possible inertia since a larger averagingwindow or generally a larger measurement duration will only wait for themeasurement result when this precision is actually required.

A provisional distance value was briefly addressed above with respect towhich the required and achieved measurement error of the measurement isfixed. As now seen, the result of a first measurement with a shortmeasurement duration or a running average with a small k or k=1 is inparticular suitable for this.

A tool is available with the variable measurement duration to measurewith the required maximum errors with the distance sensor 24 and thefirst of the two initially asked questions is answered. For the secondquestion, which maximum error actually has to be observed to set a focalposition for images of sufficient quality, a distinction should first bemade between purely optical or physical demands and application-specificdemands.

A physical depth of field range DOF_(p)(d) can be approximated by theformula DOF_(p)(d)˜2d²Nc/f². Here, d is the distance between the camera10 and the object 48; N is the numerical aperture f_(num) of theobjective of the reception optics 16 and is thus f-number dependent; cis the circle of confusion and corresponds to the degree of permittedblue of, for example, one pixel on the image sensor 18; and f is thefocal length of the objective. A number of these are accordinglyparameters of the object that are known and fixed. Further influences onthe depth of field range such as the f-number or the exposure can belargely precluded by fixing or by optimum setting.

However, specific demands of the application are not taken into accountin the physical depth of field range DOF_(p)(d). This becomes clear forthe example of code reading. It is ultimately not a question of whetherimages satisfy physical contrast criteria, but rather whether the codecan be read. In some cases, this application-specific depth of fieldrange DOF_(app) can be modeled by a factor κ that depends onapplication-specific parameters: DOFapp(d)=κDOF_(p)(d). Typicalapplication-specific parameters are here the module size, for examplemeasured in pixels per module, the code type, and last but not least thedecoding algorithm used. If this cannot be modeled by a simple factor κ,the possibility at least remains of determining DOF_(app) by simulationor experiment.

FIG. 4 shows a representation of reading attempts of a code 52 on anobject 48 at different focal positions and object distances. Light dots60 designate successful reading attempts (GoodReads) and dark dots 62unsuccessful reading attempts (NoReads). The two lines 64 follow theborder between them and the distance interval of the two linesdesignates the required application-specific depth of field rangeDOF_(app)(d) in dependence on the object distance.

Such a diagram can be produced by measurement or simulation for specificconditions with respect to said parameters such as the code type, modulesize, decoding process, exposure. An association rule in the form of afunction or table (lookup table, LUT) is thereby produced from which thecontrol and evaluation unit 38 can read, with a given provisionaldistance value, a depth of field range and thus a required maximum errorwith which it is still ensured that a code will be readable. There canbe a plurality of association rules for different conditions so thatthen a determination is made in a situation and application relatedmanner, for example in dependence on the code type, module size,exposure, and the decoder used.

FIG. 5 again illustrates how a matching measurement duration for arequired depth of field range can be found. The required depth of fieldrange that is fixed in accordance with the method just described isshown by a black line 66, on the one hand. The measurement error of adistance measurement of the distance sensor 24 is furthermore shown by agray line 68 in dependence on the measurement duration, with here themeasurement duration on the X axis being determined specifically as anaveraging depth k or as a number of individual measurements of a runningmean. The more individual measurements k enter into the averaging, thelonger therefore the measurement duration and the smaller themeasurement error becomes. This behavior is seen as constant insimplified form in FIG. 5 and is calibrated in advance. An averagingdepth of k>10 can be selected for the specific example, with here alittle buffer still being considered with respect to the actualintersection of the two lines 66, 68 at approximately k=6.

A specific example will finally be looked at. An object 40 is arrangedat a distance 0.1 m from the camera 10. Analog to FIG. 5, a requiredaveraging depth k=10 of the running mean was determined. A fictitiousmeasurement of distance values Dist could then appear as follows:

Dist1: 0.095 m Focal position is set to 0.095 m. This takes a time dTthat may well be longer than an individual distance measurement. Dist2:0.113 m Calculated mean value from two values. Dist3: 0.101 m Calculatedmean value from three values. Dist4: 0.098 m Calculated mean value fromfour values. The focal position is now set to the first distance Dist1 =0.095 m. Adjust the focal position further to the new mean value(refocusing). This is done a lot faster as a rule because the adjustmentdistance is shorter. Dist5: 0.108 m Mean value from five values,refocusing. . . . Dist10: 0.089 m Mean value from ten values,refocusing. Required k = 10 reached for the first time. Dist11: 0.106 mMean value from the last 10 values. Refocusing. Dist12: 0.101 m Meanvalue from the last 10 values. Refocusing. . . . Dist46: 0.099 m Meanvalue from the last 10 values. Refocusing Dist47: 0.531 m JUMP largerthan a defined threshold value. A new k is alsoset for the new distance.In this case, the distance is so large that the depth of field range isalready larger for an individual measurement than the measurement errorof the distance measurement (cf. FIG. 3). An averaging window where k =1 is therefore sufficient; only an individual measurement is stillrequired. The focal position is set to 0.531 m. This takes a time dTthat is easily longer [. . . etc. . . . ]

The measurement series has largely already been explained. The focalposition best known at the respective time is preferably immediatelytraveled to. This is initially only a rough setting that can requiresome adjustment time; the further steps track the focal position inaccordance with the ever better distance measurement, with these smalladjustment distances being covered fast. The focal position is exactenough for an image recording within the required depth of field rangefrom the measurement of k=10 individual distance values onward.

A special aspect results if a new object 48 enters into the detectionzone 14 or if the distance is measured after one edge to now a differentobject structure. This done at the last indicated measurement Dist47 inthe exemplary measurement series. This jump is recognized in that thenew value Dist47 differs greatly from the previous running mean. Insomewhat more formal terms, the absolute difference of the currentindividual distance value, here Dist47=0.531 m, and of the previousrunning mean, here very precisely at 0.1 m, can be compared with athreshold value for this purpose. The threshold value is oriented on theexpectable statistical fluctuation, for instance as a plurality of astandard deviation, and can be fixed in dependence on the distance orfixedly as a compromise over all the distances. The running mean iscontinued as long as said absolute difference is below the thresholdvalue. This is the case up to the measurement value Dist46. A newaveraging is started on a threshold exceeding since otherwise a mixedvalue would arise that is not significant and a new k is preferably alsoselected here.

It is conceivable to record images additionally during the focusing andto calculate values such as the contrast from the image.

1. A camera for detecting an object in a detection zone, the cameracomprising: an image sensor for recording image data, a reception opticshaving a focus adjustment unit for setting a focal position, a distancesensor for measuring a distance value from the object, and a control andevaluation unit connected to the distance sensor (24) and the focusadjustment unit to set a focal position in dependence on the distancevalue, wherein the control and evaluation unit is configured todetermine a distance value with the distance sensor via a variablemeasurement duration that is predefined in dependence on a provisionaldistance value such that a measurement error of the distance value andthus, on a recording of image data of the object, a focus deviation ofthe set focal position from an ideal focal position remains small enoughfor a required image sharpness of the image data.
 2. The camera inaccordance with claim 1, wherein the distance sensor is integrated inthe camera.
 3. The camera in accordance with claim 1, wherein thedistance sensor is configured as an optoelectronic distance sensor. 4.The camera in accordance with claim 3, wherein the optoelectronicdistance sensor is in accordance with the principle of the time offlight process.
 5. The camera in accordance with claim 1, wherein thecontrol and evaluation unit is configured to read a code content of acode on the object using the image data.
 6. The camera in accordancewith claim 1, wherein the control and evaluation unit is configured toreparameterize the distance sensor for a respective distance measurementhaving a required measurement duration.
 7. The camera system inaccordance with claim 1, wherein the distance sensor is configured toproduce individual distance measurement values after a fixed individualmeasurement time it; and wherein the control and evaluation unit isconfigured to set a required measurement duration as a multiple of theindividual measurement duration by a plurality of individualmeasurements.
 8. The camera in accordance with claim 7, wherein thecontrol and evaluation unit is configured to determine the distancevalue as a running average over a plurality of individual measurements.9. The camera in accordance with claim 8, wherein the control andevaluation unit is configured to reset the running average when anindividual distance measurement value differs by at least one thresholdvalue from the previous running average.
 10. The camera system inaccordance with claim 7, wherein the provisional distance value is anindividual distance measurement value or a previous running average oversome individual measurements.
 11. The camera in accordance with claim 1,wherein the control and evaluation unit is configured to associate astill permitted focus deviation with the distance value while observinga required image sharpness.
 12. The camera in accordance with claim 11,wherein the control and evaluation unit is configured to associate astill permitted focus deviation with the distance value while observinga required image sharpness with reference to an association rule or atable.
 13. The camera in accordance with claim 1, wherein the requiredimage sharpness is achieved when the object is still recorded with theset focal position in a depth of field range.
 14. The camera inaccordance with claim 13, wherein the depth of field range is a depth offield range determined from optical properties and/or fromapplication-specific demands.
 15. The camera in accordance with claim 1,wherein the control and evaluation unit is configured to read a codecontent of a code on the object using the image data; and wherein afocus deviation is small enough if the image sharpness therewith issufficient to read a code.
 16. The camera in accordance with claim 1,wherein the measurement duration to be set depends on at least one of acode type, a module size, and a decoding process.
 17. The camera inaccordance with claim 1, wherein the control and evaluation unit isconfigured already to vary the focal position during the measurementduration.
 18. The camera in accordance with claim 1, that is installedin a stationary manner at a conveying device that guides objects to bedetected in a direction of conveying through the detection zone.
 19. Amethod of detecting image data of an object in a detection zone, inwhich a distance value from the object is measured by a distance sensorand a focal position of a reception optics is set in dependence on thedistance value. wherein the distance value is determined over a variablemeasurement duration that is predefined in dependence on a provisionaldistance value such that a measurement error of the distance value andthus, on a recording of image data of the object, a focus deviation ofthe set focal position from an ideal focal position remains small enoughfor a required image sharpness of the image data.